/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package com.bear.fe;
import com.bear.fe.conn.*;
import java.util.Arrays;
/**
 *
 * @author libear
 */
public class Test {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) throws FileException {
        // TODO code application logic here
        testList();
    }
    
      public static void testList()throws FileException {
        FileSystemConnection conn = FileSystemConnectionFactroy.getConnection();
        byte[] bs = "hello,bear".getBytes();
        conn.start();
        conn.saveFile("f:/ffde/temp/test1.txt", bs);
        conn.saveFile("f:/ffde/temp/test2.txt", bs);   
        String[] files = conn.listFiles("f:/ffde/temp/");
        System.out.println(Arrays.asList(files));
        System.out.println(new String(conn.getContent(files[0])));
        //conn.commit();
        conn.rollback();
    }
      
    public static void testGetContent()throws FileException {
        FileSystemConnection conn = FileSystemConnectionFactroy.getConnection();
        byte[] bs = "hello,bear".getBytes();
        conn.start();
        conn.saveFile("f:/ffde/temp/test1.txt", bs);
        conn.saveFile("f:/ffde/temp/test2.txt", bs);
        String content = new String(conn.getContent("f:/ffde/temp/test1.txt"));
        System.out.println(content);
        //conn.commit();
        conn.rollback();
    }
    
    public static void testSave() throws FileException {
        FileSystemConnection conn = FileSystemConnectionFactroy.getConnection();
        byte[] bs = "hello,bear".getBytes();
        conn.start();
        conn.saveFile("f:/ffde/temp/test1.txt", bs);
        conn.saveFile("f:/ffde/temp/test2.txt", bs);
        //conn.commit();
        conn.rollback();
    }
    
    
    
    public static void testSaveRemove() throws FileException {
        FileSystemConnection conn = FileSystemConnectionFactroy.getConnection();
        byte[] bs = "hello,bear".getBytes();
        conn.start();
        conn.saveFile("f:/ffde/temp/test1.txt", bs);
        conn.saveFile("f:/ffde/temp/test2.txt", bs);
        conn.removeFile("f:/ffde/temp/test1.txt");
        //conn.commit();
        conn.rollback();
    }
    
     public static void testRemove() throws FileException {
        FileSystemConnection conn = FileSystemConnectionFactroy.getConnection();
        byte[] bs = "hello,bear".getBytes();
        conn.start();
        conn.saveFile("f:/ffde/temp/test1.txt", bs);
        conn.saveFile("f:/ffde/temp/test2.txt", bs);
        conn.commit();
        FileSystemConnection conn1 = FileSystemConnectionFactroy.getConnection();
        conn1.removeFile("f:/ffde/temp/test1.txt");
        conn1.removeFile("f:/ffde/temp/test2.txt");
        conn1.rollback();
    }
     
     

}
